#include <bits/stdc++.h>

using namespace std;

ifstream fin("color.in");
ofstream fout("color.out");

const int N = 200005;

int t, n, A[N];

int eval(int i)
{
    int l[] = {-1, -1}, s = 0;
    for (int j = 0; j < n; j++)
    {
        if (~l[i >> j & 1] && A[l[i >> j & 1]] == A[j]) s += A[j];
        l[i >> j & 1] = j;
    }
    return s;
}

int main()
{
    fin >> t;
    while (t--)
    {
        fin >> n;
        for (int i = 0; i < n; fin >> A[i++]);

        int ans = 0;
        for (int i = 0; i < 1 << n; ans = max(ans, eval(i++)));

        fout << ans << '\n';
    }

    return 0;
}